<html>
<head><meta charset="utf-8"><title>const wf bounds implementation · t-compiler/const-eval · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/index.html">t-compiler/const-eval</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html">const wf bounds implementation</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="204812573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204812573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204812573">(Jul 23 2020 at 15:27)</a>:</h4>
<p>new topic to discuss how this should be implemented. Relevant discussions in <a href="https://github.com/rust-lang/rust/issues/68436">#68436</a> and <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60ConstEvaluatable.60.20generic.20functions/">https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60ConstEvaluatable.60.20generic.20functions/</a>.</p>



<a name="204812626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204812626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204812626">(Jul 23 2020 at 15:27)</a>:</h4>
<blockquote>
<p>you can implement the required_const_bounds by creating a query that runs on mir_const or mir_validated</p>
</blockquote>
<p>I am actually not quite sure what you mean there</p>



<a name="204812641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204812641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204812641">(Jul 23 2020 at 15:27)</a>:</h4>
<p>so my idea would be the following</p>



<a name="204812794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204812794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204812794">(Jul 23 2020 at 15:28)</a>:</h4>
<p>for each const in the where bounds, add a <code>PredicateKind::ConstEvaluatable</code> to <code>param_env.caller_bounds</code></p>



<a name="204812909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204812909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204812909">(Jul 23 2020 at 15:29)</a>:</h4>
<p>and if we then have a <code>PredicateKind::ConstEvaluatable</code> in the body, we first check if it is const evaluatable using the implementation in <a href="https://github.com/rust-lang/rust/issues/74595">#74595</a></p>



<a name="204813063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204813063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204813063">(Jul 23 2020 at 15:30)</a>:</h4>
<p>and if this is not the case, we check if a <code>PredicateKind::ConstEvaluatable</code> exists in the caller bounds whose mir can be "unified" with the mir of what we want to check</p>



<a name="204813248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204813248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204813248">(Jul 23 2020 at 15:32)</a>:</h4>
<hr>



<a name="204813439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204813439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204813439">(Jul 23 2020 at 15:34)</a>:</h4>
<p>What I am now still unsure of is how can we correctly "unify" mir here</p>



<a name="204813559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204813559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204813559">(Jul 23 2020 at 15:35)</a>:</h4>
<p>I do <strong>not</strong> want to use <code>optimized_mir</code> because that makes us dependent on optimizations during typeck, which is bad™</p>



<a name="204813712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204813712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204813712">(Jul 23 2020 at 15:36)</a>:</h4>
<p>So we probably need a query as described by <span class="user-mention" data-user-id="124288">@oli</span> which we call for anon consts before stealing either <code>mir_const</code> or <code>mir_validated</code></p>



<a name="204813764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204813764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204813764">(Jul 23 2020 at 15:36)</a>:</h4>
<p>whose result we then compare here to check if an expression is implied by the where bounds</p>



<a name="204813946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204813946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204813946">(Jul 23 2020 at 15:38)</a>:</h4>
<p>What should that query return?</p>



<a name="204814169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204814169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204814169">(Jul 23 2020 at 15:40)</a>:</h4>
<p>Just cloning the given mir and then walking that seems okish, if quite bad for perf</p>



<a name="204814629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204814629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204814629">(Jul 23 2020 at 15:44)</a>:</h4>
<p>Also, how stable is the generated mir? I kind of fear that 2 slightly different expressions end up having the same mir and breaking due to internal changes</p>



<a name="204820644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204820644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204820644">(Jul 23 2020 at 16:31)</a>:</h4>
<p>there's no need to clone, you can just process that generated MIR and emit the list of where clauses that must be held</p>



<a name="204820700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204820700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204820700">(Jul 23 2020 at 16:31)</a>:</h4>
<p>not sure what format these should be in, but probably something like <code>Predicates</code> iirc?</p>



<a name="204820825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204820825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204820825">(Jul 23 2020 at 16:32)</a>:</h4>
<blockquote>
<p>emit the list of where clauses</p>
</blockquote>
<p>So if we have <code>[0; std::mem::size_of::&lt;T&gt; + N + 7]</code></p>



<a name="204820883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204820883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204820883">(Jul 23 2020 at 16:32)</a>:</h4>
<p>I would expect us to require exactly one where clause, being <code>ConstEvaluatable(std::mem::size_of::&lt;T&gt; + N + 7)</code></p>



<a name="204820893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204820893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204820893">(Jul 23 2020 at 16:32)</a>:</h4>
<p>yes</p>



<a name="204820924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204820924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204820924">(Jul 23 2020 at 16:33)</a>:</h4>
<p>that's what I'd expect, too</p>



<a name="204820969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204820969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204820969">(Jul 23 2020 at 16:33)</a>:</h4>
<p>so you can even just return a <code>&amp;'tcx [&amp;'tcx ty::Const&lt;'tcx&gt;]</code></p>



<a name="204821029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821029">(Jul 23 2020 at 16:33)</a>:</h4>
<p>?</p>



<a name="204821077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821077">(Jul 23 2020 at 16:34)</a>:</h4>
<p>you want to return <code>ty::Const</code> here</p>



<a name="204821106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821106">(Jul 23 2020 at 16:34)</a>:</h4>
<p>wait. First of all, on what do you want to call this query?</p>



<a name="204821127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821127">(Jul 23 2020 at 16:34)</a>:</h4>
<p>on the <code>DefId</code> of the function</p>



<a name="204821147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821147">(Jul 23 2020 at 16:34)</a>:</h4>
<p>well, when walking the MIR, what do you do? you collect all constants and want them as where clauses</p>



<a name="204821202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821202">(Jul 23 2020 at 16:35)</a>:</h4>
<p>I want to only walk the mir of <code>std::mem::size_of::&lt;T&gt; + N + 7</code> here</p>



<a name="204821214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821214">(Jul 23 2020 at 16:35)</a>:</h4>
<p>huh wait what?</p>



<a name="204821237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821237">(Jul 23 2020 at 16:35)</a>:</h4>
<p>so when typechecking a function, we end up with a bunch of <code>PredicateKind::ConstEvaluatable</code> for every unevaluated constant</p>



<a name="204821361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821361">(Jul 23 2020 at 16:36)</a>:</h4>
<blockquote>
<p>lcnr: and if we then have a PredicateKind::ConstEvaluatable in the body, we first check if it is const evaluatable using the implementation in <a href="https://github.com/rust-lang/rust/issues/74595">#74595</a></p>
<p>lcnr: and if this is not the case, we check if a PredicateKind::ConstEvaluatable exists in the caller bounds whose mir can be "unified" with the mir of what we want to check</p>
</blockquote>



<a name="204821363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821363">(Jul 23 2020 at 16:36)</a>:</h4>
<p>oh, I got a bit confused there, I thought the query was gonna run on the function</p>



<a name="204821373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821373">(Jul 23 2020 at 16:36)</a>:</h4>
<p>so we don't miss any anon consts</p>



<a name="204821502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821502">(Jul 23 2020 at 16:37)</a>:</h4>
<p>Hmm, that seems weird to me considering that we already have most of the infrastructure for const wf implemented</p>



<a name="204821522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821522">(Jul 23 2020 at 16:37)</a>:</h4>
<p>yea</p>



<a name="204821530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821530">(Jul 23 2020 at 16:37)</a>:</h4>
<p>I just misunderstood</p>



<a name="204821545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821545">(Jul 23 2020 at 16:37)</a>:</h4>
<p>didn't think this through and just went with what I understood</p>



<a name="204821607"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821607" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821607">(Jul 23 2020 at 16:38)</a>:</h4>
<p>So e.g. walking mir also has to consider trait bounds which were generated during typeck which I don't think is that easily doable</p>



<a name="204821665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821665">(Jul 23 2020 at 16:38)</a>:</h4>
<p>so... you basically want a query that returns <code>true</code> when the anon const uses generics</p>



<a name="204821716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821716">(Jul 23 2020 at 16:39)</a>:</h4>
<p>We already have that in <a href="https://github.com/rust-lang/rust/issues/74595">#74595</a>, don't we?</p>



<a name="204821772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821772">(Jul 23 2020 at 16:39)</a>:</h4>
<p>I want to check if a anon const is found in the caller bounds of a given function</p>



<a name="204821782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821782">(Jul 23 2020 at 16:39)</a>:</h4>
<p>jop, but you need the MIR, and I don't know if computing the MIR for anon consts of a function causes cylces during typeck</p>



<a name="204821881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204821881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204821881">(Jul 23 2020 at 16:40)</a>:</h4>
<p>We already have to built the MIR to check that rn <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span> so that won't cause additional cycle errors here</p>



<a name="204822157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204822157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204822157">(Jul 23 2020 at 16:42)</a>:</h4>
<p>I think the only missing piece for me is how to check if two different MIR are equal</p>



<a name="204822271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204822271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204822271">(Jul 23 2020 at 16:43)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">size_of</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()]</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">size_of</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()];</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="204822273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204822273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204822273">(Jul 23 2020 at 16:43)</a>:</h4>
<p>ok, cool</p>



<a name="204822295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204822295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204822295">(Jul 23 2020 at 16:43)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span>  already sketched that out</p>



<a name="204822314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204822314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204822314">(Jul 23 2020 at 16:43)</a>:</h4>
<p>so how can I check if the anon const in the where bound is the same as the anon const in repeat expr</p>



<a name="204822422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204822422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204822422">(Jul 23 2020 at 16:44)</a>:</h4>
<p>iirc it's to implement <code>TyRelation</code> for, but it may have been some other relation/comparison thing</p>



<a name="204822437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204822437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204822437">(Jul 23 2020 at 16:44)</a>:</h4>
<p>searching</p>



<a name="204822752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204822752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204822752">(Jul 23 2020 at 16:47)</a>:</h4>
<p>yea, <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/relate/trait.Relate.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/relate/trait.Relate.html</a></p>



<a name="204822862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204822862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204822862">(Jul 23 2020 at 16:48)</a>:</h4>
<p>just checking local types and all basic block contents likely suffices, but better double check that</p>



<a name="204822912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204822912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204822912">(Jul 23 2020 at 16:48)</a>:</h4>
<p>basically skip all things like variable names, debug info and other things that don't influence the semantics of the MIR</p>



<a name="204822950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204822950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204822950">(Jul 23 2020 at 16:49)</a>:</h4>
<p>can we implement a desugaring manually and get the same mir?</p>



<a name="204822983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204822983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204822983">(Jul 23 2020 at 16:49)</a>:</h4>
<p>so e.g. reimplement a <code>for</code> loop using <code>while</code></p>



<a name="204823016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204823016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204823016">(Jul 23 2020 at 16:49)</a>:</h4>
<p>likely</p>



<a name="204823047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204823047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204823047">(Jul 23 2020 at 16:49)</a>:</h4>
<p>but not if you check the relevant info in MIR</p>



<a name="204823133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204823133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204823133">(Jul 23 2020 at 16:50)</a>:</h4>
<p>yeah, that's probably the hard part <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span> I really don't want to leak implementation details this way</p>



<a name="204823608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204823608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204823608">(Jul 23 2020 at 16:54)</a>:</h4>
<p>I guess we could compute equivalence on the HIR... Not sure, let's let some others weigh in</p>



<a name="204823986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204823986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204823986">(Jul 23 2020 at 16:57)</a>:</h4>
<p>hir is also partially desugared afaik (but it should be less dangerous than mir)</p>



<a name="204824175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204824175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204824175">(Jul 23 2020 at 16:59)</a>:</h4>
<p>we might also start by slowly increasing the working subset, so it should be fairly safe to only start with builtin integer arithmetic</p>



<a name="204824207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204824207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204824207">(Jul 23 2020 at 16:59)</a>:</h4>
<p>I have a solution for you, gimme a sec</p>



<a name="204824852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204824852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204824852">(Jul 23 2020 at 17:04)</a>:</h4>
<p>ok</p>



<a name="204824856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204824856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204824856">(Jul 23 2020 at 17:04)</a>:</h4>
<p>so.</p>



<a name="204824874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204824874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204824874">(Jul 23 2020 at 17:04)</a>:</h4>
<p>we can go several evil ways, and all of them are cool</p>



<a name="204824962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204824962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204824962">(Jul 23 2020 at 17:05)</a>:</h4>
<p>Evil way number 1 (the one that I'm all for, but has maybe questions on how to extend in the future): symbolically execute the MIR of the anon const and generate a symbol (term tree) that represents that MIR abstractly</p>



<a name="204825085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204825085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204825085">(Jul 23 2020 at 17:06)</a>:</h4>
<p>Evil way number 2: similar to number 1, but instead of doing symbolic execution, build an SSA dependency graph and  use that as the abstract representation of the MIR</p>



<a name="204825154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204825154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204825154">(Jul 23 2020 at 17:06)</a>:</h4>
<p>Both ways just error out whenever you hit a terminator other than <code>Goto</code>, <code>Return</code> or <code>Assert</code>.</p>



<a name="204825188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204825188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204825188">(Jul 23 2020 at 17:06)</a>:</h4>
<p>oh, function calls are also ok</p>



<a name="204826081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204826081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204826081">(Jul 23 2020 at 17:15)</a>:</h4>
<p>I am a bit lost on this conversation. Can I ask about the basics a little bit?<br>
Like (1): why do we want to know if a const generic type is well formed before computing it? Apart from performance reasons. I ask because if I understand it correctly, we can catch all ill-formed cases at monomorphization time, right?<br>
And to accompany that, (2): is it feasible <em>at all</em> to <strong>not</strong> bubble up the const expressions in <code>where</code> clauses (i.e. infer them) and at the same time, decide if the type is well formed? And is it possible to do so <strong>before monomorphization</strong>?</p>



<a name="204826343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204826343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204826343">(Jul 23 2020 at 17:17)</a>:</h4>
<p>we can autogenerate the where bounds</p>



<a name="204826396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204826396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204826396">(Jul 23 2020 at 17:18)</a>:</h4>
<p>so you don't need to write them</p>



<a name="204826425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204826425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204826425">(Jul 23 2020 at 17:18)</a>:</h4>
<p>that means that changing the body of a function will be semver breaking</p>



<a name="204826660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204826660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204826660">(Jul 23 2020 at 17:21)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/const.20wf.20bounds.20implementation/near/204826425">said</a>:</p>
<blockquote>
<p>that means that changing the body of a function will be semver breaking</p>
</blockquote>
<p>This has strong implications upon RFC 2000 then, right? In the sense that the feature that const generics will be has some usability constraints that have to be discussed</p>



<a name="204826668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204826668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204826668">(Jul 23 2020 at 17:21)</a>:</h4>
<p>/ addressed</p>



<a name="204826947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204826947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204826947">(Jul 23 2020 at 17:23)</a>:</h4>
<p>On the other hand... for which primitive types is this a concern? Only <code>usize</code> and <code>isize</code>, right?</p>



<a name="204827326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204827326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204827326">(Jul 23 2020 at 17:27)</a>:</h4>
<p>Because for overflowing arithmetic in <code>uX</code> and <code>iX</code>, the API owner could define what semantics to use (clamping arithmetic =&gt; <code>a::MAX + 1</code> results in <code>a::MAX</code>, and cyclic arithmetic, where <code>a::MAX + 1</code> results in <code>a::MIN</code>.</p>



<a name="204827376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204827376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204827376">(Jul 23 2020 at 17:27)</a>:</h4>
<p>Unless I'm missing other malformed operations, which I probably am tbh</p>



<a name="204827572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204827572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204827572">(Jul 23 2020 at 17:29)</a>:</h4>
<p>Also, this is sort of... a weird problem. Like, this suppossedly only affects very extreme cases, right? Maybe we could address those issues by relaxing some constraint whenever we hit those cases. Like, this is probably a bad fallback, but imagine that if you went past <code>uX::MAX</code>, you could fallback into a type with the same semantics (up to memory layout differences) but with different layout, like <code>u(2X)</code>.</p>



<a name="204827696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204827696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204827696">(Jul 23 2020 at 17:31)</a>:</h4>
<p>I dunno. Maybe it's not that weird. Maybe you can just bubble up the operations and it'll feel natural. But that's how I feel about this topic.</p>



<a name="204827785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204827785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204827785">(Jul 23 2020 at 17:31)</a>:</h4>
<p><em>(bbl, lunch time)</em></p>



<a name="204828552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204828552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204828552">(Jul 23 2020 at 17:38)</a>:</h4>
<p>sry for just skipping over the comments by <span class="user-mention silent" data-user-id="212698">Félix Fischer</span> here. i don't have a good and satisfying answer for this myself, and find it fairly exhausting</p>



<a name="204828637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204828637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204828637">(Jul 23 2020 at 17:39)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/const.20wf.20bounds.20implementation/near/204824962">said</a>:</p>
<blockquote>
<p>Evil way number 1 (the one that I'm all for, but has maybe questions on how to extend in the future): symbolically execute the MIR of the anon const and generate a symbol (term tree) that represents that MIR abstractly</p>
</blockquote>
<p>does this solve problems we have with looking at mir directly?</p>



<a name="204828884"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204828884" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204828884">(Jul 23 2020 at 17:41)</a>:</h4>
<blockquote>
<p>oh, function calls are also ok</p>
</blockquote>
<p>so we pretty much require any more complex operations to be inside of functions</p>



<a name="204828902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204828902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204828902">(Jul 23 2020 at 17:41)</a>:</h4>
<p>or constants / associated consts</p>



<a name="204828924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204828924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204828924">(Jul 23 2020 at 17:42)</a>:</h4>
<p>which actually looks like a good solution to me</p>



<a name="204828965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204828965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204828965">(Jul 23 2020 at 17:42)</a>:</h4>
<p>I think</p>



<a name="204829050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204829050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204829050">(Jul 23 2020 at 17:42)</a>:</h4>
<p>so for things like <code>N + M + 4</code> we don't have to worry about syntactic sugar and stuff</p>



<a name="204829085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204829085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204829085">(Jul 23 2020 at 17:43)</a>:</h4>
<p>and for more complex operations methods are more useful anyways, as we otherwise have to duplicate a lot of code</p>



<a name="204829644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204829644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204829644">(Jul 23 2020 at 17:47)</a>:</h4>
<p>So this would mean that const generic expressions may contain basic arithmetic and calls to arbitrary <code>const fn</code>, which should be fairly simple to learn <em>for users</em></p>



<a name="204830403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204830403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204830403">(Jul 23 2020 at 17:52)</a>:</h4>
<p>So to get this forward we probably have to do the following:</p>
<ol>
<li>write a short summary of why this is needed (which should hopefully answer <span class="user-mention silent" data-user-id="212698">Félix Fischer</span>s questions)</li>
<li>write a short summary of how we want to implement this (what I wrote above, but slightly cleaner)</li>
<li>get the <code>const-eval</code> team and <span class="user-mention silent" data-user-id="119009">eddyb</span> + <span class="user-mention silent" data-user-id="121053">varkor</span> to agree that this is the right way forward</li>
<li>lang team + compiler MCP</li>
<li>implement</li>
</ol>



<a name="204830496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204830496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204830496">(Jul 23 2020 at 17:52)</a>:</h4>
<p>so I personally feel motivated to push 2-5 forward <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> <span class="user-mention" data-user-id="124288">@oli</span> can I get you to write a summary for 1?</p>



<a name="204830554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204830554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204830554">(Jul 23 2020 at 17:53)</a>:</h4>
<p>or firstly, do you also think this is the right approach. I hope I didn't misunderstand what you wanted to achieve here</p>



<a name="204830658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204830658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204830658">(Jul 23 2020 at 17:54)</a>:</h4>
<p>yeaaa. I owe you a summary, the tab is still open</p>



<a name="204830766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204830766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204830766">(Jul 23 2020 at 17:55)</a>:</h4>
<p>ok, yea that plan and your comments above it make total sense</p>



<a name="204830784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204830784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204830784">(Jul 23 2020 at 17:55)</a>:</h4>
<p>I'll start writing that summary now</p>



<a name="204832130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204832130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204832130">(Jul 23 2020 at 18:04)</a>:</h4>
<p>It's okay <span class="user-mention" data-user-id="216206">@lcnr</span>, don't worry, take care of yourself <span aria-label="heart" class="emoji emoji-2764" role="img" title="heart">:heart:</span></p>



<a name="204832265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204832265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204832265">(Jul 23 2020 at 18:05)</a>:</h4>
<p>And fwiw, I don't think any programming language community has tried to answer these questions before? Not with Rust's restrictions, at any rate (I'm thinking that probably some dependently typed langs have dwelved into this, but again as far as I'm aware, they have less restrictions than Rust does)</p>



<a name="204832623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204832623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204832623">(Jul 23 2020 at 18:09)</a>:</h4>
<p>(After reading the rest): I like your plan <span aria-label="blush" class="emoji emoji-1f60a" role="img" title="blush">:blush:</span></p>



<a name="204843505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204843505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204843505">(Jul 23 2020 at 19:30)</a>:</h4>
<p>Summary written... time to turn off the internet and hope I'm still happy reading notifications tomorrow</p>



<a name="204843992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204843992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204843992">(Jul 23 2020 at 19:35)</a>:</h4>
<p>:)</p>



<a name="204844001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204844001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204844001">(Jul 23 2020 at 19:35)</a>:</h4>
<p>Thanks <span class="user-mention" data-user-id="124288">@oli</span>!</p>



<a name="204844133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204844133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204844133">(Jul 23 2020 at 19:36)</a>:</h4>
<p>I'm now reading at right after Proposal no. 1, and I have to say, this has been really illuminating so far. Thank you!!</p>



<a name="204844169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204844169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204844169">(Jul 23 2020 at 19:36)</a>:</h4>
<p>Oli's summary can be found here: <a href="https://github.com/rust-lang/rust/issues/68436#issuecomment-663190861">summary</a></p>



<a name="204846037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204846037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204846037">(Jul 23 2020 at 19:54)</a>:</h4>
<p><span class="user-mention" data-user-id="212698">@Félix Fischer</span> <a href="https://github.com/rust-lang/rust/issues/68436#issuecomment-663200323">https://github.com/rust-lang/rust/issues/68436#issuecomment-663200323</a> oh no</p>



<a name="204846067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204846067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204846067">(Jul 23 2020 at 19:54)</a>:</h4>
<p>that's something I didn't think about before</p>



<a name="204846298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204846298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204846298">(Jul 23 2020 at 19:56)</a>:</h4>
<p>so you can "fix" things like this by using</p>
<div class="codehilite"><pre><span></span><code><span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">foo_wf_condition</span><span class="p">(</span><span class="n">v</span>: <span class="kt">usize</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Option</span><span class="o">&lt;</span><span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="n">C</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">         </span><span class="nb">Some</span><span class="p">(</span><span class="mi">25</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="n">C</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="nb">None</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>as the wf condition</p>



<a name="204846509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204846509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204846509">(Jul 23 2020 at 19:58)</a>:</h4>
<p>but hmm, I don't think control flow aware bounds work in the general case, good old mr turing is at it once again here</p>



<a name="204846555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204846555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204846555">(Jul 23 2020 at 19:58)</a>:</h4>
<p>wait, your function is fine</p>



<a name="204846577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204846577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204846577">(Jul 23 2020 at 19:59)</a>:</h4>
<p>we only require expressions using const parameters to be wf if they are used inside of types</p>



<a name="204846594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204846594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204846594">(Jul 23 2020 at 19:59)</a>:</h4>
<p>so you have to add 0 bounds to foo</p>



<a name="204846613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204846613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204846613">(Jul 23 2020 at 19:59)</a>:</h4>
<p>you would have to add bounds when using foo in an array length</p>



<a name="204846642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204846642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204846642">(Jul 23 2020 at 19:59)</a>:</h4>
<p>at which point you can just bind on <code>foo</code> itself</p>



<a name="204846758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204846758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204846758">(Jul 23 2020 at 20:00)</a>:</h4>
<p>and you can't really "conditionally use a type", so you would probably always directly use <code>foo</code> as a bound</p>



<a name="204848347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204848347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204848347">(Jul 23 2020 at 20:15)</a>:</h4>
<p>well, answered on the issue itself <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="204849854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204849854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204849854">(Jul 23 2020 at 20:29)</a>:</h4>
<p>Yas, now it's a lot clearer. Thanks <span class="user-mention" data-user-id="216206">@lcnr</span></p>



<a name="204849856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204849856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204849856">(Jul 23 2020 at 20:29)</a>:</h4>
<p>:)</p>



<a name="204883025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204883025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204883025">(Jul 24 2020 at 06:21)</a>:</h4>
<p>Will still have to clean this up, but a basic version for the second bullet point can be found here: <a href="https://hackmd.io/z7LKv6WKRkiw2WC7KDkvYw?view">https://hackmd.io/z7LKv6WKRkiw2WC7KDkvYw?view</a></p>
<p>Still have to proof read it a few times and do some cleanup here</p>



<a name="204905928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204905928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204905928">(Jul 24 2020 at 11:41)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> that's why we want to limit this to basic math and assignments for now. This way we don't really have to care about desugarings. If we want to be super super strict, we can also just allow const fn calls and expect you to move more complex things to function calls</p>



<a name="204905998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204905998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204905998">(Jul 24 2020 at 11:42)</a>:</h4>
<p>(or introduce generic constants)</p>



<a name="204906033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204906033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204906033">(Jul 24 2020 at 11:42)</a>:</h4>
<p>but I think starting out with a version that supports math and no control flow makes sense</p>



<a name="204906037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204906037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204906037">(Jul 24 2020 at 11:42)</a>:</h4>
<p>you can still get control flow by using const fns</p>



<a name="204906077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204906077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204906077">(Jul 24 2020 at 11:43)</a>:</h4>
<p>Oh... I should read the entire post before commenting</p>



<a name="204906079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204906079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204906079">(Jul 24 2020 at 11:43)</a>:</h4>
<p>sorry</p>



<a name="204906141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204906141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204906141">(Jul 24 2020 at 11:44)</a>:</h4>
<p>the terminator list should contain <code>Call</code>, too</p>



<a name="204906502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204906502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204906502">(Jul 24 2020 at 11:50)</a>:</h4>
<p>I'm not sure if a query taking the param env scales well from the query system perspective. Instead I propose to add a query going from <code>DefId</code> to the abstract representation and then appyling that to the anon const in the param env, the anon const in the body and relating those abstract things</p>



<a name="204906522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204906522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204906522">(Jul 24 2020 at 11:50)</a>:</h4>
<p>so you basically get a <code>query anon_to_abstract(DefId) -&gt; AbstractConst</code></p>



<a name="204916138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204916138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204916138">(Jul 24 2020 at 13:40)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/const.20wf.20bounds.20implementation/near/204906522">said</a>:</p>
<blockquote>
<p>so you basically get a <code>query anon_to_abstract(DefId) -&gt; AbstractConst</code></p>
</blockquote>
<p>Thanks for looking at this. </p>
<p>That's what I meant, I want to use  <code>query anon_to_abstract(DefId) -&gt; AbstractConst</code> or more likely <code>query anon_to_abstract(DefId) -&gt; Option&lt;AbstractConst&gt;</code>. We can then cache this on disk and don't have to worry about invalidating other queries as often</p>



<a name="204916203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204916203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204916203">(Jul 24 2020 at 13:41)</a>:</h4>
<p>Will update this, if you want I can also give you editing permission</p>



<a name="204918166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204918166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204918166">(Jul 24 2020 at 13:58)</a>:</h4>
<p>the hackmd is now just part of <code>RustLang</code> <span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span></p>



<a name="204919019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204919019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204919019">(Jul 24 2020 at 14:04)</a>:</h4>
<p>So, <code>Option</code> because the query is fallible, but only fallible in cases of errors, right?</p>



<a name="204919044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204919044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204919044">(Jul 24 2020 at 14:04)</a>:</h4>
<p>In that case we can move to <code>Result&lt;AbstractConst, ErrorReported&gt;</code></p>



<a name="204919564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204919564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204919564">(Jul 24 2020 at 14:09)</a>:</h4>
<p>The abstract representations of constants in the mir bodies don't need to be preserved cross crate, right? only those in the where bounds</p>



<a name="204919620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204919620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204919620">(Jul 24 2020 at 14:09)</a>:</h4>
<p>we could have two queries in that case, which should cut down the new metadata from this by about half, when compared to the full version</p>



<a name="204923856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204923856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204923856">(Jul 24 2020 at 14:41)</a>:</h4>
<p>We only need <code>AbstractConst</code> for polymorphic anonymous constants</p>



<a name="204923964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204923964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204923964">(Jul 24 2020 at 14:42)</a>:</h4>
<p>We can either check this before calling <code>anon_to_abstract</code>, in which case the calling query probably depends on <code>tcx.def_kind</code></p>



<a name="204924002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204924002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204924002">(Jul 24 2020 at 14:42)</a>:</h4>
<p>or check this inside of <code>anon_to_abstract</code> and return a dummy value (None) in this case</p>



<a name="204924305"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204924305" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204924305">(Jul 24 2020 at 14:44)</a>:</h4>
<p>So checking this inside of <code>anon_to_abstract</code> seems both more error resistant, i.e. if we end up with an inconsistent <code>ConstEvaluatable</code> due to a previous error and then call <code>anon_to_abstract</code> we would ICE if we didn't call it inside of <code>mir_const</code> as the mir is now stolen</p>



<a name="204924521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204924521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204924521">(Jul 24 2020 at 14:46)</a>:</h4>
<p>and might be more efficient, as we don't have to recompute <code>mir_const</code> if the <code>def_kind</code> changes (we probably have to do so anyways because when does the <code>def_kind</code> change and the mir stays exactly the same) so that point is fairly moot</p>



<a name="204924675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204924675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204924675">(Jul 24 2020 at 14:47)</a>:</h4>
<blockquote>
<p>but only fallible in cases of errors</p>
</blockquote>
<p>We can either also return <code>None</code> here, or actually use <code>Result&lt;Option&lt;AbstractConst&gt;, ErrorReported&gt;</code></p>



<a name="204924923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204924923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204924923">(Jul 24 2020 at 14:49)</a>:</h4>
<p>I am not exactly sure how to deal with this, but that's also something which should be more clear once we actually start implementing this</p>



<a name="204927127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204927127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204927127">(Jul 24 2020 at 15:04)</a>:</h4>
<p>sgtm</p>



<a name="204927491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204927491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204927491">(Jul 24 2020 at 15:07)</a>:</h4>
<p>The pi types rfc is a damn treat (reading this rn because I want to see how that wanted to handle this)</p>



<a name="204927854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204927854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204927854">(Jul 24 2020 at 15:11)</a>:</h4>
<blockquote>
<p>it has some severe disadvantages: most importantly, the type checking becomes undecidable.</p>
</blockquote>
<p>rusts type checking already is <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span></p>



<a name="204927891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204927891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204927891">(Jul 24 2020 at 15:11)</a>:</h4>
<p>O_o?</p>



<a name="204927997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204927997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204927997">(Jul 24 2020 at 15:12)</a>:</h4>
<p><a href="https://www.reddit.com/r/rust/comments/5y4x9r/challenge_rusts_type_system_is_not_turing_complete/">https://www.reddit.com/r/rust/comments/5y4x9r/challenge_rusts_type_system_is_not_turing_complete/</a></p>



<a name="204928092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204928092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204928092">(Jul 24 2020 at 15:13)</a>:</h4>
<p>i think somewhere in the RFC says that this already happens in the compiler</p>



<a name="204928351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204928351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204928351">(Jul 24 2020 at 15:15)</a>:</h4>
<p>probably in the new one, the old (closed) pi types rfc did not mention it afaik. I am looking at <a href="https://github.com/rust-lang/rfcs/pull/1931">https://github.com/rust-lang/rfcs/pull/1931</a> rn, I think the merged const generics rfc (rfcs/pull/2000) mostly dodges that question iirc</p>



<a name="204928398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204928398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204928398">(Jul 24 2020 at 15:15)</a>:</h4>
<p>i think this is the wrong topic :D</p>



<a name="204928469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204928469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204928469">(Jul 24 2020 at 15:16)</a>:</h4>
<p>for this discussion? <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> it most definitely is</p>



<a name="204928491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204928491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204928491">(Jul 24 2020 at 15:16)</a>:</h4>
<p>(deleted)</p>



<a name="204929118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204929118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204929118">(Jul 24 2020 at 15:20)</a>:</h4>
<p>So that rfc is actually interesting here and somewhat on topic (it intruduces const wf bounds for the old pi types design)</p>



<a name="204929907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204929907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204929907">(Jul 24 2020 at 15:26)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/const.20wf.20bounds.20implementation/near/204929118">said</a>:</p>
<blockquote>
<p>So that rfc is actually interesting here and somewhat on topic (it intruduces const wf bounds for the old pi types design)</p>
</blockquote>
<p>with <em>that rfc</em> I meant <a href="https://github.com/rust-lang/rfcs/pull/1932">https://github.com/rust-lang/rfcs/pull/1932</a></p>



<a name="204933242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204933242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204933242">(Jul 24 2020 at 15:56)</a>:</h4>
<p>so I think <a href="https://hackmd.io/z7LKv6WKRkiw2WC7KDkvYw">https://hackmd.io/z7LKv6WKRkiw2WC7KDkvYw</a> is fine now. It isn't a master work but it should serve as a good enough summary.</p>
<p>Anything I should still mention here/elaborate on?</p>



<a name="204935124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204935124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204935124">(Jul 24 2020 at 16:13)</a>:</h4>
<p>I think it's ready, too, though I don't know how detailed T-lang MCPs are supposed to be</p>



<a name="204935454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204935454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204935454">(Jul 24 2020 at 16:16)</a>:</h4>
<p>Yeah, will have to look into this and also maybe get <span class="user-mention silent" data-user-id="256759">boats</span>  involved then</p>



<a name="204935849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204935849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204935849">(Jul 24 2020 at 16:20)</a>:</h4>
<p>So, @t-compiler/const-eval, <span class="user-mention" data-user-id="119009">@eddyb</span> <span class="user-mention" data-user-id="121053">@varkor</span></p>
<p>@oli and me have a plan to move const wf bounds forward, the plan as well as the link to what we want to fix here can be found in <a href="https://hackmd.io/z7LKv6WKRkiw2WC7KDkvYw">https://hackmd.io/z7LKv6WKRkiw2WC7KDkvYw</a></p>
<p>In case there are any questions, concerns or suggestions here, please speak up.</p>



<a name="204935910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204935910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204935910">(Jul 24 2020 at 16:20)</a>:</h4>
<p>Can't ping the working group <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span> not sure who else is interested in this</p>



<a name="204936136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204936136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204936136">(Jul 24 2020 at 16:22)</a>:</h4>
<p>what does well-formed mean in this context?</p>



<a name="204938182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204938182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204938182">(Jul 24 2020 at 16:39)</a>:</h4>
<p>that they can be evaluated with any given concrete value</p>



<a name="204938278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204938278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204938278">(Jul 24 2020 at 16:40)</a>:</h4>
<p>so <code>N - 1</code> is not well formed in general, as <code>0 - 1</code> would cause a const eval error</p>



<a name="204938808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204938808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204938808">(Jul 24 2020 at 16:45)</a>:</h4>
<p>A good example, where requiring this is useful, is something like</p>
<div class="codehilite"><pre><span></span><code><span class="k">trait</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">test</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">test</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span>: <span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="mi">64</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">size_of</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()];</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="204938909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204938909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204938909">(Jul 24 2020 at 16:46)</a>:</h4>
<p>Is <code>Foo</code> implemented for <code>()</code>? There is certainly no where bound preventing this here</p>



<a name="204939057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204939057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204939057">(Jul 24 2020 at 16:47)</a>:</h4>
<p>but any code which tries to actually use this ends up with an error. This error would only happen with at least <code>cargo build</code>. <code>cargo check</code> wouldn't actually catch anything here</p>



<a name="204940071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204940071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204940071">(Jul 24 2020 at 16:56)</a>:</h4>
<p>Here is a more interesting example where incorrect const expressions are quite bad: <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=c1f6a435b64e660354935e996e80e6e8">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=c1f6a435b64e660354935e996e80e6e8</a></p>



<a name="204940176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204940176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204940176">(Jul 24 2020 at 16:57)</a>:</h4>
<p>If we allow expressions in array lengths this can happen a lot easier, for example if one method uses <code>N - 1</code> as an array length.</p>



<a name="204943412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204943412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204943412">(Jul 24 2020 at 17:27)</a>:</h4>
<p>hmmm interesting</p>



<a name="204943422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204943422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204943422">(Jul 24 2020 at 17:27)</a>:</h4>
<p>(deleted)</p>



<a name="204943450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204943450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204943450">(Jul 24 2020 at 17:27)</a>:</h4>
<p>(deleted)</p>



<a name="204944236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204944236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204944236">(Jul 24 2020 at 17:33)</a>:</h4>
<p>and how strict would this be? Should the user always add bounds to guarantee well-formedness or it is just a warning?</p>



<a name="204944510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204944510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204944510">(Jul 24 2020 at 17:35)</a>:</h4>
<p>because that'd mean that stuff like</p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">duplicate</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">(</span><span class="n">a</span>: <span class="p">[</span><span class="kt">u32</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="p">])</span><span class="w"> </span>-&gt; <span class="p">[</span><span class="kt">u32</span><span class="p">;</span><span class="w"> </span><span class="p">{</span><span class="mi">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">N</span><span class="p">}]</span><span class="w"></span>
</code></pre></div>


<p>would need a <code>where {2 * N &lt; usize::max_value() }</code> to be accepted by the compiler</p>



<a name="204945079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204945079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204945079">(Jul 24 2020 at 17:39)</a>:</h4>
<p>I also have a more implementation related question, what should happen with this <code>AbstractConst</code>?</p>



<a name="204945364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204945364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204945364">(Jul 24 2020 at 17:41)</a>:</h4>
<p>consts in the signature are automatically treated the same way as where bounds</p>



<a name="204945488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204945488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204945488">(Jul 24 2020 at 17:42)</a>:</h4>
<p>so you don't need a where bound, and if you had <code>[u32; {2 * N}]</code> in the body of the function, you'd need a <code>where (2 * N)</code> where bound</p>



<a name="204945598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204945598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204945598">(Jul 24 2020 at 17:43)</a>:</h4>
<p>you don't need to specify ranges or anything, there's no proof system checking whether your where bounds enable the constants in the body. There's "simply"  a system that checks that all constants in the body exist in the  where bounds, too</p>



<a name="204945688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204945688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204945688">(Jul 24 2020 at 17:44)</a>:</h4>
<p>(unless the constant contains no generics, then it is evaluated, which also satisfies well-formedness or errors)</p>



<a name="204945852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204945852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204945852">(Jul 24 2020 at 17:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="132916">Christian Poveda</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/const.20wf.20bounds.20implementation/near/204945079">said</a>:</p>
<blockquote>
<p>I also have a more implementation related question, what should happen with this <code>AbstractConst</code>?</p>
</blockquote>
<p>that's covered in the last paragraph of the hackmd, if its use was unclear, let's extend the hackmd</p>



<a name="204946292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204946292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204946292">(Jul 24 2020 at 17:49)</a>:</h4>
<p>oh OK now I get it</p>



<a name="204947027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204947027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204947027">(Jul 24 2020 at 17:56)</a>:</h4>
<p>so basically the idea behind <code>AbstractConst</code> is to be able to check which constants inside a function's body satisfy <code>ConstEvaluatable</code>. Is that right?</p>



<a name="204947091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204947091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204947091">(Jul 24 2020 at 17:57)</a>:</h4>
<p>or did I misinterpret the doc?</p>



<a name="204948973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204948973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204948973">(Jul 24 2020 at 18:13)</a>:</h4>
<p>The root idea of <code>AbstractConst</code> is that we have something that we can compare against another <code>AbstractConst</code>, because we can't really compare <code>mir::Body</code> in a useful manner. So we compute an <code>AbstractConst</code> which is similar to what you did with <code>sire</code></p>



<a name="204949016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204949016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204949016">(Jul 24 2020 at 18:13)</a>:</h4>
<p>and yes, then we use that to compare a constant's <code>AbstractConst</code> with all <code>where</code> bound <code>AbstractConst</code>s</p>



<a name="204949029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204949029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204949029">(Jul 24 2020 at 18:14)</a>:</h4>
<p>if there's a match, the constant is considered well formed</p>



<a name="204950510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204950510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204950510">(Jul 24 2020 at 18:27)</a>:</h4>
<p>Man this sounds exciting</p>



<a name="204950514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204950514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204950514">(Jul 24 2020 at 18:27)</a>:</h4>
<p>I like it</p>



<a name="204952936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204952936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204952936">(Jul 24 2020 at 18:50)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> can this method be used to do CTFE check of properties of a const generic parameter?</p>



<a name="204952974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204952974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204952974">(Jul 24 2020 at 18:50)</a>:</h4>
<p>uh, what are "properties" in this situation?</p>



<a name="204952980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204952980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204952980">(Jul 24 2020 at 18:50)</a>:</h4>
<p>you can specify arbitrary bounds that are not required by the body</p>



<a name="204952997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204952997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204952997">(Jul 24 2020 at 18:51)</a>:</h4>
<p>just like you can specify excessive trait bounds</p>



<a name="204953009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953009">(Jul 24 2020 at 18:51)</a>:</h4>
<p>Like for example I do <code>where (is_even(N))</code><br>
And <code>is_even</code> is a function that does nothing if the number is even and panics if it is odd</p>



<a name="204953029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953029">(Jul 24 2020 at 18:51)</a>:</h4>
<p>sure</p>



<a name="204953030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953030">(Jul 24 2020 at 18:51)</a>:</h4>
<p>Is a <code>const fn</code>*</p>



<a name="204953039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953039">(Jul 24 2020 at 18:51)</a>:</h4>
<p>Really??</p>



<a name="204953048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953048">(Jul 24 2020 at 18:51)</a>:</h4>
<p>That is so fancy!</p>



<a name="204953059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953059">(Jul 24 2020 at 18:51)</a>:</h4>
<p>I love it!</p>



<a name="204953145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953145">(Jul 24 2020 at 18:52)</a>:</h4>
<p>you can't use this knowledge inside at compile-time except for the return value of <code>is_even(N)</code>, but you can use this knowledge arbitrarily in the runtime code</p>



<a name="204953219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953219">(Jul 24 2020 at 18:53)</a>:</h4>
<p>I don't understand that last message at all XD</p>



<a name="204953239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953239">(Jul 24 2020 at 18:53)</a>:</h4>
<p>Well, <code>is_even</code> in this case would not return anything</p>



<a name="204953250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953250">(Jul 24 2020 at 18:53)</a>:</h4>
<p>It would just panic if the number is not even</p>



<a name="204953295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953295">(Jul 24 2020 at 18:54)</a>:</h4>
<p>=&gt; giving a compile-time error</p>



<a name="204953377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953377">(Jul 24 2020 at 18:55)</a>:</h4>
<p>Maybe instead of panicking I would do an <code>assert!</code></p>



<a name="204953394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953394">(Jul 24 2020 at 18:55)</a>:</h4>
<p>But you get what I mean?</p>



<a name="204953433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953433">(Jul 24 2020 at 18:55)</a>:</h4>
<p>I'd be piggybacking on the WF check to do arbitrary (CTFE-restricted) checks</p>



<a name="204953501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953501">(Jul 24 2020 at 18:56)</a>:</h4>
<p>sure that works, my question is: what do you want to do with these checks?</p>



<a name="204953522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953522">(Jul 24 2020 at 18:56)</a>:</h4>
<p>like what does an example (arbitrarily artificial is totally ok) look like?</p>



<a name="204953547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953547">(Jul 24 2020 at 18:56)</a>:</h4>
<p>Ensure soundness of const-generic types at compile time</p>



<a name="204953549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953549">(Jul 24 2020 at 18:56)</a>:</h4>
<p>Ah okay</p>



<a name="204953551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953551">(Jul 24 2020 at 18:56)</a>:</h4>
<p>Em</p>



<a name="204953584"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953584" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953584">(Jul 24 2020 at 18:57)</a>:</h4>
<p>So I've been wanting to do a const-generic toy thing for years now with integers and prime numbers</p>



<a name="204953626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953626">(Jul 24 2020 at 18:57)</a>:</h4>
<p>Basically a library for computations in integers-modulo-p numbers, where p is a prime</p>



<a name="204953658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953658">(Jul 24 2020 at 18:57)</a>:</h4>
<p>Where const generics help is in ensuring that you're never adding two integers that have a different p</p>



<a name="204953717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953717">(Jul 24 2020 at 18:58)</a>:</h4>
<p>Right? Because 1 mod 2 is not the same as 1 mod 3</p>



<a name="204953735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953735">(Jul 24 2020 at 18:58)</a>:</h4>
<p>oh I have a simpler example: there are certain operations that are illegal on zsts, but only exhibit bad behaviour at runtime, so you can now slap an <code>where (assert!(size_of::&lt;T&gt;() != 0))</code> on your function/datastructure</p>



<a name="204953752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953752">(Jul 24 2020 at 18:58)</a>:</h4>
<p>Therefore adding, substracting, equality, etc, make no sense between two numbers with different p</p>



<a name="204953781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953781">(Jul 24 2020 at 18:58)</a>:</h4>
<p>YES!</p>



<a name="204953787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953787">(Jul 24 2020 at 18:59)</a>:</h4>
<p>That's exactly it</p>



<a name="204953806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953806">(Jul 24 2020 at 18:59)</a>:</h4>
<p>Where it also helps with my example is with ensuring that p is a prime</p>



<a name="204953831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953831">(Jul 24 2020 at 18:59)</a>:</h4>
<p>That way you don't have to assert it every time you create one of these numbers</p>



<a name="204953832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953832">(Jul 24 2020 at 18:59)</a>:</h4>
<p>another thing is that we can now make <code>transmute</code> not-so-special anymore, because we can just slap <code>where (assert!(size_of::&lt;T&gt;() == size_of::&lt;U&gt;()))</code> on the intrinsic and let the regular system handle</p>



<a name="204953859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953859">(Jul 24 2020 at 18:59)</a>:</h4>
<p>oh yea, and ranged integer types!</p>



<a name="204953926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953926">(Jul 24 2020 at 19:00)</a>:</h4>
<p>See? This is super cool!</p>



<a name="204953930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953930">(Jul 24 2020 at 19:00)</a>:</h4>
<p>XD</p>



<a name="204953933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204953933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204953933">(Jul 24 2020 at 19:00)</a>:</h4>
<p>the cool thing about the transmute thing is that you can bubble this information upwards now, so you can finally use transmute on generic parameters</p>



<a name="204956825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204956825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204956825">(Jul 24 2020 at 19:28)</a>:</h4>
<p>I'm imagining a bunch of dark bounds for arrays right now</p>



<a name="204956891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204956891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204956891">(Jul 24 2020 at 19:29)</a>:</h4>
<p>like for</p>
<div class="codehilite"><pre><span></span><code>fn split_in_half&lt;const N: usize&gt;(a: [u32; N]) -&gt; [u32; N / 2]
</code></pre></div>



<a name="204957258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204957258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204957258">(Jul 24 2020 at 19:33)</a>:</h4>
<p>or things like</p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">get</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">I</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">(</span><span class="n">arr</span><span class="p">[</span><span class="n">N</span><span class="p">;</span><span class="w"> </span><span class="kt">u32</span><span class="p">])</span><span class="w"> </span>-&gt; <span class="kt">u32</span> <span class="nc">where</span><span class="w"> </span><span class="p">(</span><span class="n">assert</span><span class="o">!</span><span class="p">(</span><span class="n">I</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="n">N</span><span class="p">))</span><span class="w"></span>
</code></pre></div>



<a name="204973070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204973070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204973070">(Jul 24 2020 at 22:28)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> these transmute uses may be of interest to <span class="user-mention" data-user-id="224872">@Ryan Levick</span> , <span class="user-mention" data-user-id="219211">@Jack Wrenn</span> and maybe <span class="user-mention" data-user-id="224471">@Lokathor</span> who are working on a related RFC in a WG.</p>



<a name="204973117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204973117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204973117">(Jul 24 2020 at 22:29)</a>:</h4>
<p>const transmute? did that merge or something?</p>



<a name="204975813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204975813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204975813">(Jul 24 2020 at 23:17)</a>:</h4>
<p>inside of constants and statics, I think <a href="https://github.com/rust-lang/rust/issues/72920">#72920</a> is the most recent PR here</p>



<a name="204976761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204976761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204976761">(Jul 24 2020 at 23:36)</a>:</h4>
<p>But from what I can tell this discussion isn't really about const transmute, but instead on expressing the current bounds of <code>transmute</code> as const well-formed bounds instead of checking it as part of the intrinsic</p>



<a name="204976802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204976802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204976802">(Jul 24 2020 at 23:37)</a>:</h4>
<p>So with const wf bounds we will be able to write <code>fn transmute&lt;T, U&gt;(v: T) -&gt; U where (assert_eq!(std::mem::size_of::&lt;T&gt;(), std::mem::size_of::&lt;U&gt;())), { ... }</code></p>



<a name="204976976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204976976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204976976">(Jul 24 2020 at 23:40)</a>:</h4>
<p>which will work the same way as the current checks on transmute, but can actually be propagated upwards by functions using transmute once this lands on stable (which will take a while).</p>
<div class="codehilite"><pre><span></span><code><span class="k">unsafe</span><span class="w"> </span><span class="k">fn</span> <span class="nf">from_bits</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">v</span>: <span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">size_of</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()])</span><span class="w"> </span>-&gt; <span class="nc">T</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="p">(</span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">size_of</span>::<span class="o">&lt;</span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">size_of</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()]</span><span class="o">&gt;</span><span class="p">(),</span><span class="w"> </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">size_of</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()))),</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">transmute</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="204977636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/204977636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#204977636">(Jul 24 2020 at 23:54)</a>:</h4>
<p>This is still fairly far from getting finalized though, so we might be putting the cart in front of the horse here</p>



<a name="205060957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/205060957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#205060957">(Jul 26 2020 at 17:52)</a>:</h4>
<p>is it there an equivalent concept to specialization in this kind of bounds?</p>



<a name="205061445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/205061445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#205061445">(Jul 26 2020 at 18:07)</a>:</h4>
<p>Hmm, not really <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span> (edit: read the rest, this comment is somewhat misleading)</p>



<a name="205061489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/205061489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#205061489">(Jul 26 2020 at 18:08)</a>:</h4>
<p>So all const wf bounds will be opaque and will always be assumed to be potentially overlapping, so the following will not work</p>



<a name="205061502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/205061502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#205061502">(Jul 26 2020 at 18:09)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Bar</span><span class="o">&lt;</span><span class="n">N</span><span class="o">&gt;</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="p">(</span><span class="n">assert</span><span class="o">!</span><span class="p">(</span><span class="n">N</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="mi">0</span><span class="p">))</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Bar</span><span class="o">&lt;</span><span class="n">N</span><span class="o">&gt;</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="p">(</span><span class="n">assert</span><span class="o">!</span><span class="p">(</span><span class="n">N</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="p">))</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</code></pre></div>



<a name="205061557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/205061557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#205061557">(Jul 26 2020 at 18:10)</a>:</h4>
<p>In terms of how this will interact with specialization, it will probably work like others bound</p>



<a name="205061573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/205061573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#205061573">(Jul 26 2020 at 18:11)</a>:</h4>
<p>So it should be possible to write the following:</p>
<div class="codehilite"><pre><span></span><code><span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Bar</span><span class="o">&lt;</span><span class="n">N</span><span class="o">&gt;</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="p">(</span><span class="n">assert</span><span class="o">!</span><span class="p">(</span><span class="n">N</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="mi">0</span><span class="p">))</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">     </span><span class="k">default</span> <span class="k">fn</span><span class="w"> </span><span class="n">foo</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="p">{</span><span class="w"> </span><span class="n">println</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;default&quot;</span><span class="p">)</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Bar</span><span class="o">&lt;</span><span class="n">N</span><span class="o">&gt;</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="p">(</span><span class="n">assert</span><span class="o">!</span><span class="p">(</span><span class="n">N</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="mi">0</span><span class="p">)),</span><span class="w"> </span><span class="p">(</span><span class="n">assert</span><span class="o">!</span><span class="p">(</span><span class="n">N</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="mi">1</span><span class="p">))</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="p">{</span><span class="w"> </span><span class="n">println</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;specialized&quot;</span><span class="p">)</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="205061692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/205061692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#205061692">(Jul 26 2020 at 18:14)</a>:</h4>
<p>You can mostly specialize here by just branching on const values though, so that's always an option:</p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">println</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;Hey&quot;</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">println</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;Ho&quot;</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="205062055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/205062055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#205062055">(Jul 26 2020 at 18:25)</a>:</h4>
<p>Ohh!</p>



<a name="205062092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/205062092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#205062092">(Jul 26 2020 at 18:26)</a>:</h4>
<p>Branching is a really good idea</p>



<a name="205062096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/205062096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#205062096">(Jul 26 2020 at 18:26)</a>:</h4>
<p>Because with compile-time opts the branching can be eliminated <span aria-label="rainbow" class="emoji emoji-1f308" role="img" title="rainbow">:rainbow:</span><span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span></p>



<a name="205062101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/205062101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#205062101">(Jul 26 2020 at 18:26)</a>:</h4>
<p>I'm really liking this</p>



<a name="205062105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/205062105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#205062105">(Jul 26 2020 at 18:27)</a>:</h4>
<p>(Me too!)</p>



<a name="205476289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/205476289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#205476289">(Jul 30 2020 at 13:12)</a>:</h4>
<p>I also just realized that this should be the same as const equality checks, i.e. this is a way to compare two const expressions, so we should also be able to allow the following with this <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span> we better get this right <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="205476347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/205476347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#205476347">(Jul 30 2020 at 13:13)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">test</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">2</span><span class="p">]</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">[</span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">2</span><span class="p">]</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="205476791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/205476791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#205476791">(Jul 30 2020 at 13:16)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="256759">@boats</span>, it would seem really weird to be able to equate two constants for the sake of const well-formedness while not being able to unify them during typeck</p>



<a name="205477050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/205477050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#205477050">(Jul 30 2020 at 13:18)</a>:</h4>
<p>What's appropriate here if we want to implement this from the view of the lang team? (without caring about stabilization for now)</p>



<a name="205477145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/205477145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#205477145">(Jul 30 2020 at 13:19)</a>:</h4>
<p>is an MCP enough or do we need an FCP here or even an eRFC?</p>



<a name="205628044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/205628044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#205628044">(Jul 31 2020 at 18:54)</a>:</h4>
<p>well, I wrote a text for <code>T-lang</code>... not sure what to do with it</p>



<a name="205628879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20wf%20bounds%20implementation/near/205628879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20wf.20bounds.20implementation.html#205628879">(Jul 31 2020 at 19:01)</a>:</h4>
<p><a href="#narrow/stream/213817-t-lang/topic/const.20equality.20.2B.20wf">https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/const.20equality.20.2B.20wf</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>